﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

public static class RectExtension
{
    public static Point GetCenter(this Rect rect)
    {
        return new Point(rect.X + rect.Width * 0.5, rect.Y + rect.Height * 0.5);
    }

    public static void SetCenter(ref this Rect rect, double x, double y)
    {
        rect.X = x - rect.Width * 0.5;
        rect.Y = y - rect.Height * 0.5;
    }

    public static void SetCenter(ref this Rect rect, Point center)
    {
        SetCenter(ref rect, center.X, center.Y);
    }
}
